<?php date_default_timezone_set('Australia/Brisbane'); ?>
<script src="<?php echo base_url(); ?>assets/js/week.js"></script>
<h1>Settings</h1>
<div>
	
	<form action="<?php echo site_url('admin/settings'); ?>" method="POST">

		<h3>Unit Settings</h3>

		<label for="unit_code">Unit Code</label>
		<input type="text" name="unit_code" id="" value="<?php if ( isset( $settings['unit_code'] ) ) { echo $settings['unit_code']; } ?>">

		<br>

		<label for="unit_name">Unit Name</label>
		<input type="text" name="unit_name" id="" value="<?php if ( isset( $settings['unit_name'] ) ) { echo $settings['unit_name']; } ?>">

		<br>

		<h3>Cron Settings</h3>

		<label><input type="radio" name="cron_enabled" id="" value="1" style="width:auto;" <?php if (isset($settings['cron_enabled']) && $settings['cron_enabled']) { echo "checked"; } ?>> Enable automated emails to at-risk students</label>
		<label style="margin-top:0;"><input type="radio" name="cron_enabled" id="" value="0" style="width:auto;" <?php if (isset($settings['cron_enabled']) && ! $settings['cron_enabled']) { echo "checked"; } ?>> Only email administrator</label>

		<label for="cron_key">Cron Security Key</label>
		<input type="text" name="cron_key" id="" value="<?php if ( isset( $settings['cron_key'] ) ) { echo $settings['cron_key']; } ?>">

		<h3>Email Settings</h3>

		<label><input type="radio" name="email_passwords" id="" value="1" style="width:auto;" <?php if (isset($settings['email_passwords']) && $settings['email_passwords']) { echo "checked"; } ?>> Email passwords to students</label>
		<label style="margin-top:0;"><input type="radio" name="email_passwords" id="" value="0" style="width:auto;" <?php if (isset($settings['email_passwords']) && ! $settings['email_passwords']) { echo "checked"; } ?>> Display passwords on screen</label>

		<label for="administrator_email">Administrator Email</label>
		<input type="text" name="administrator_email" id="" value="<?php if ( isset( $settings['administrator_email'] ) ) { echo $settings['administrator_email']; } ?>">

		<br>

		<label for="administrator_name">Administrator Name</label>
		<input type="text" name="administrator_name" id="" value="<?php if ( isset( $settings['administrator_name'] ) ) { echo $settings['administrator_name']; } ?>">

		<br>
		
		<h3>Teaching Week Settings</h3>
		<label for="first_week">First University Week Number</label>
		<input type="text" name="first_week" id="first_week" value="<?php if ( isset( $settings['first_week'] ) ) { echo $settings['first_week']; } ?>">
		
		
		<?php if ( isset( $settings['first_week'] ) ) {
			//Date of Monday of Week Number
			$date = date( "F j", strtotime(date('Y')."W".str_pad($settings['first_week'], 2, "0", STR_PAD_LEFT)) );
			echo '<div id="date_of_week">'.$date.'</div>';
			} ?>

		<br>
		
		<label for="weeks">Semester Weeks</label>
		<input type="text" name="weeks" id="" value="<?php if ( isset( $settings['weeks'] ) ) { echo $settings['weeks']; } ?>">

		<br>

		<input type="submit" value="Update Settings">

	</form>

</div>